package main

import "fmt"

func main() {
	a := make([]int, 3)
	b := make([]int, 3, 5)

	fmt.Println(a, b)
	fmt.Println(len(a), len(b))
	// 使用append（）给切片添加元素
	var numbers []int
	for i := 0; i < 10; i++ {
		numbers = append(numbers, i)
		// cap（）查看切片的容量 %p 查看地址
		fmt.Printf("len: %d cap: %d pointer: %p\n", len(numbers), cap(numbers), numbers)
	}
	// 使用append（）给切片一次性添加多个元素
	var car []string
	// 添加一个元素
	car = append(car, "oldboy1")
	// 添加多个元素
	car = append(car, "oldboy2", "oldboy3", "oldboy4")
	// 添加切片
	team := []string{"odlboy5", "oldboy6", "oldboy7"}
	car = append(car, team...)
	// 打印切片
	fmt.Println(car)
}
